#! /usr/bin/env python
# -*- coding: utf-8 -*-

# *************************************************************
#  Copyright (c) Huoty - All rights reserved
#
#      Author: Huoty <sudohuoty@gmail.com>
#  CreateTime: 2017-05-25 09:56:25
# *************************************************************

import threading


n = 0


def foo():
    global n
    n += 1

def main():
    global n
    n = 0
    
    threads = []
    for i in range(100):
        t = threading.Thread(target=foo)
        threads.append(t)

    for t in threads:
        t.start()

    for t in threads:
        t.join()


# Script starts from here

if __name__ == "__main__":
    for _ in xrange(100000):
        main()
        if n != 100:
            print n
